name: Lint
on: [pull_request]

permissions:
  contents: read
  pull-requests: read

jobs:
  golangci:
    name: golangci-lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0 # needed for `only-new-issues` to compare diffs
      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version-file: 'tools/go.mod'
      - name: golangci-lint
        uses: golangci/golangci-lint-action@v4
        with:
          version: latest
          args: "--config .golintci.yml"
          only-new-issues: true

  tfproviderlint:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest]
    steps:
      - uses: actions/checkout@v4
      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version-file: 'tools/go.mod'
      - run: make terraform-provider-lint
